#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

LL sum(LL x) {
    return x * (x + 1) / 2;
}

int t, x, y;

int main(int argc, char const *argv[])
{
    scanf("%d", &t);
    for (int kk=0; kk<t; ++kk) {
        scanf("%d%d", &x, &y);

        if (x > y) swap(x, y);
        int del = y - x;


        if (del == 0) {
            puts("0");
            continue;
        }
        int l = 0, r = del;
        while (l < r-1) {
            int m = (l+r) >> 1;
            if (sum(m) <= del) l = m;
            else r = m;
        }

        LL remain = del - sum(l);
        // printf("l=%d, remain=%lld\n", l, remain);
        int ans = l + (remain > 0);
        // printf("sum(ans)=%lld, ans=%d\n", sum(ans), ans);
        // printf("%lld %d\n", sum(ans) + x + y, ans);
        while ((sum(ans) + x + y) % 2) ++ans;
        printf("%d\n", ans);
    }
    return 0;
}